
/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __FILELIST_ABILITY_SLICE_H__
#define __FILELIST_ABILITY_SLICE_H__

#include <ability_loader.h>
#include <components/ui_label.h>
#include <components/ui_image_view.h>
#include <components/ui_scroll_view.h>
#include <components/root_view.h>

#include "list_view.h"
#include "popup_dialog.h"
#include "event_listener.h"

namespace OHOS {
class FileListAbilitySlice : public AbilitySlice {
public:
    FileListAbilitySlice() = default;
    ~FileListAbilitySlice() override;
    int DialogDisplay(const char *msg, int type, int timeout);
protected:
    void OnStart(const Want &want) override;
    void OnInactive() override;
    void OnActive(const Want &want) override;
    void OnBackground() override;
    void OnStop() override;
private:
    RootView *rootView_ { nullptr };
    UIScrollView *listView_ { nullptr };
    UIImageView *backButton_ { nullptr };
    UIImageView *backArea_ { nullptr };
    UIImageView *background_ { nullptr };
    UILabel *titleLabel_ { nullptr };

    PopupDialog *dialogWin_ { nullptr };

    int listType_ = FILE_TYPE_VIDEO;

    void GetDeaultListView(int type);
    void SetListView(const char *dirName);
    void AddItem(const char *fullPath, int idx);
    void SetHead();

    static constexpr int FILE_TYPE_VIDEO = 0;
    static constexpr int FILE_TYPE_IMAGE = 1;

    static constexpr int LINE_HEIGHT = 72;
    static constexpr int LINE_NBR = 6;
    static constexpr int LINE_POS = 8;

    static constexpr int ICON_START_X = 32;
    static constexpr int ICON_START_Y = 22;
    static constexpr int ICON_WIDTH = 28;
    static constexpr int ICON_HEIGHT = 28;

    static constexpr int TEXT_START_X = 80;
    static constexpr int TEXT_START_Y = 0;

    static constexpr int LISTVIEW_START_X = 16;
    static constexpr int LISTVIEW_START_Y = 0;

    static constexpr int BACK_ICON_XPOS = 24;
    static constexpr int BACK_ICON_YPOS = 24;
    static constexpr int BACK_ICON_WIDTH = 48;
    static constexpr int BACK_ICON_HEIGHT = 48;

    static constexpr int TITLE_XPOS = 80;
    static constexpr int TITLE_YPOS = 0;
    static constexpr int TITLE_WIDTH = 300;
    static constexpr int TITLE_HEIGHT = 96;
};
}

#endif  /* __FILELIST_ABILITY_SLICE_H__ */
